export default {
  namespaced: true,
  state: {
    isShowToast: false,

    // 提示消息
    toastMsg: "",
    // 提示类型(控制图标) success warning danger
    toastType: "",
  },
  mutations: {
    changeIsShowToast(state, payload) {
      state.isShowToast = payload.isShow;
      if (payload.isShow) {
        state.toastMsg = payload.msg;
        state.toastType = payload.type;
      }
    },
  },
  actions: {
    asyncIsShowToast(context, payload) {
      context.commit("changeIsShowToast", {
        isShow: true,
        msg: payload.msg,
        type: payload.type,
      });
      setTimeout(() => {
        context.commit("changeIsShowToast", { isShow: false });
      }, 2000);
    },
  },
};

/**
 * 提示信息：
 *     灵活  (提示内容,提示图标)
 */
